package org.zhenggn.designpattern;

/**
 * Created by zhengguinan on 2017/8/25.
 */
public class Test {
    public static void main(String[] args) {
        long deptId = 68L;
            long id = 2L;
            long mergeId = mergeId(deptId,id);
            System.out.println(mergeId);

            System.out.println(parseSellerPart(mergeId));

            System.out.println(parseOrderPart(mergeId));




    }

    /**
     *
     * @param sellerPart
     * @param orderPart
     * @return
     */
    public static long mergeId(long sellerPart, long orderPart) {
        long result = (sellerPart << 42) | orderPart;
        return result;
    }

    /**
     *
     * @param mergedId
     * @return
     */
    public static long parseSellerPart(long mergedId) {
        long sellerPart = mergedId >> 42;
        return sellerPart;
    }

    /**
     *
     * @param meredId
     * @return
     */
    public static long parseOrderPart(long mergedId) {
        long t = ~(127L << 42);
        long result = mergedId & t;

        return result;
    }
}

